<html>
<head>

<style type="text/css" title="currentStyle" media="screen">
	@import "vtes_exp.css";
</style>

<script type="text/javascript">

	function popup(mylink, windowname) {
		if (! window.focus)return true;
		var href;
		if (typeof(mylink) == 'string')
		   href=mylink;
		else
		   href=mylink.href;
		window.open(href, windowname, 'width=240,height=320,scrollbars=no');
			return false;
		}
	
	function go() {
		document.forms[0].submit();
		}
	
</script>

</head>
<body>

<?php

$_GET["card"] = str_replace("{","'",$_GET["card"]);

$expansions = array(2 => "jyh", "vts", "ds", "ah", "sab", "sbw", "fn", "bld", "cam", "an", "bh", "geh", "ten", "kmw", "lob", "nor", "3rd", "soc", "pro", "dem");

$c = 0;
$file = fopen("db_images.csv","r");
fgetcsv($file, 1000, ",");   // ditch the first line
while  (($images = fgetcsv($file, 1000, ",")) !== FALSE) {
    if ($images[0] == $_GET["card"])
        break;
    $c++;
    }
fclose($file);

$file = fopen("db_rarities.csv","r");
fgetcsv($file, 1000, ",");   // ditch the first line
for ($i = 0; $i < $c; $i++) {  // skip every card before the one we want
    fgetcsv($file, 1000, ",");
    }
$rarities = fgetcsv($file, 1000, ",");   // grab the rarity data for our card
fclose($file);
?>

<div id="inspect_image">
<?php
echo "<img src=\"/ebay/";
if (isset($_GET["exp"])) {
    foreach ($expansions as $key => $val) {
        if ($val == $_GET["exp"]) {
            echo $images[$key];
            break;
            }
        }
    }
else
    echo $images[1];
echo "\">";
?>
</div>

<div id="inspect_expansions">
<table class="inspect_expansions_table">
<?php
foreach ($rarities as $key => $val) {
    if ($key <= 1)
        continue;
    if ($val == " ")
        continue;
    echo "<tr><td class=\"title\"><img src=\"icon/icon_".$expansions[$key]."_th.jpg\" alt=\"".$expansions[$key]."\"></td>";
    echo '<td ';
    switch (substr($val,0,1)) {
        case "R":
            echo 'class="card_rare">';
            break;
        case "U":
        case "V":
            echo 'class="card_unc">';
            break;
        case "C":
            echo 'class="card_common">';
            break;
        case "A":
        case "B":
        case "P":
            echo 'class="card_pre">';
            break;
        case "2":   // Promos have the date in the rarity field.
            echo 'class="card_promo">';
            break;
        default:
            echo '>';
            break;
        }
    if ($images[$key] == 'x')
        echo "x";
    elseif ($images[$key] !== '' and $images[$key] !== ' ') {
        echo "<a href=\"image.php?";
        echo "card=".str_replace("'","{",$images[0])."&";
        echo "exp=".$expansions[$key]."\">";
        echo "<img src=\"th/".substr($images[$key],0,-4)."_th.jpg\" border=\"0\">";
        echo "</a>";
        }
    echo "</td></tr>\n";
    } ?>
</table>
</div>
